package com.xinan.system.meet;

import java.util.List;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

@TableBind(tableName = "tb_meet")
public class TbMeet extends Model<TbMeet> {

	private static final long serialVersionUID = 1L;

	public static final TbMeet dao = new TbMeet();

	// columns START
	private String ID = "id"; // 主键
	private String TITLE = "title"; // 会议名称
	private String TYPE = "type"; // 会议类型
	private String REMARK = "remark"; // 备注
	private String FEEMEET = "feemeet"; // 总指导价
	private String TEACHERID = "teacherid"; // 老师
	private String CREATETIME = "createtime"; // 创建时间
	private String CREATEID = "createid"; // 创建者

	public void setId(int value) {
		set(ID, value);
	}

	public int getId() {
		return get(ID);
	}

	public void setTitle(String value) {
		set(TITLE, value);
	}

	public String getTitle() {
		return get(TITLE);
	}

	public void setType(String value) {
		set(TYPE, value);
	}

	public String getType() {
		return get(TYPE);
	}

	public void setFeemeet(int value) {
		set(FEEMEET, value);
	}

	public int getFeemeet() {
		return get(FEEMEET);
	}

	public void setTeacherid(int value) {
		set(TEACHERID, value);
	}

	public int getTeacherid() {
		return get(TEACHERID);
	}
	
	public void setRemark(String value) {
		set(REMARK, value);
	}

	public String getRemark() {
		return get(REMARK);
	}

	public void setCreatetime(String value) {
		set(CREATETIME, value);
	}

	public String getCreatetime() {
		return get(CREATETIME);
	}

	public void setCreateid(int value) {
		set(CREATEID, value);
	}

	public int getCreateid() {
		return get(CREATEID);
	}

	// columns END

	public List<TbMeet> findAll() {
		return find("select * from tb_meet");
	}

	/**
	 * @param where
	 * @return Record
	 */
	public List<Record> findAlls(String where) {
		String sqlExp = " from tb_meet";
		if (StrKit.notBlank(where)) {
			sqlExp += " where " + where;
		}
		return Db.find("select * " + sqlExp);

	}

	/**
	 * 获取所有会议信息
	 * 
	 * @date 2015年4月8日 下午3:12:19
	 * @author FLY的狐狸 369191470@qq.com
	 * @return List<Record>
	 */
	public List<Record> findAllSelect() {
		return Db.find("select id,title as text from tb_meet");
	}

	public Page<TbMeet> page(int pageNumber, int pageSize, String where) {
		String sqlExp = "from tb_meet";
		if (StrKit.notBlank(where)) {
			sqlExp += " where " + where;
		}
		return paginate(pageNumber, pageSize, "select *", sqlExp);
	}

	/**
	 * 列表查询，拼接会议类型
	 * 
	 * @date 2015年4月8日 上午11:13:36
	 * @author FLY的狐狸 369191470@qq.com
	 * @param pageNumber
	 * @param pageSize
	 * @param where
	 * @return
	 */
	public Page<TbMeet> query(int pageNumber, int pageSize, String where) {
		String sqlExp = "from tb_meet t left join codes c on c.code = t.type" //
		+ " left join tb_meet_teacher th on t.teacherid=th.id" ;
		if (StrKit.notBlank(where)) {
			sqlExp += " where " + where;
		}
		return paginate(pageNumber, pageSize, "select t.*,c.name as typename,th.name as teachername", sqlExp);
	}
}
